home *** CD-ROM | disk | FTP | other *** search
- unit bsPolyglotDemoFrm;
-
- interface
-
- uses
- Windows, Messages, SysUtils,
- {$IFDEF D6_OR_HIGHER}
- Variants,
- {$ENDIF}
- Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, TypInfo, DB, Grids,
- DBGrids, ADODB, bsPolyglotUn, bsPolyglotDemoMdl, Menus, ActnList;
-
- type
- TbsPolyglotDemoForm = class(TForm)
- cbLanguages: TComboBox;
- Label1: TLabel;
- Memo1: TMemo;
- Label2: TLabel;
- Button1: TButton;
- Panel1: TPanel;
- ds: TADODataSet;
- DataSource1: TDataSource;
- dsFirstName: TStringField;
- dsLastName: TStringField;
- dsSalary: TCurrencyField;
- ComboBox1: TComboBox;
- Label3: TLabel;
- RadioGroup1: TRadioGroup;
- Button2: TButton;
- Panel2: TPanel;
- DBGrid1: TDBGrid;
- bsPolyglotTranslator1: TbsPolyglotTranslator;
- Label4: TLabel;
- MainMenu1: TMainMenu;
- ActionList1: TActionList;
- Action1: TAction;
- Action2: TAction;
- Action11: TMenuItem;
- Action21: TMenuItem;
- PopupMenu1: TPopupMenu;
- Action12: TMenuItem;
- Action22: TMenuItem;
- Button3: TButton;
- Button4: TButton;
- procedure FormCreate(Sender: TObject);
- procedure cbLanguagesChange(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- procedure FillDataset;
- procedure FillLanguages;
- public
- { Public declarations }
- end;
-
- var
- bsPolyglotDemoForm: TbsPolyglotDemoForm;
-
- implementation
-
- {$R *.dfm}
-
- resourcestring
- strYouSelected = 'You selected: ';
-
- procedure TbsPolyglotDemoForm.FillDataset;
- procedure AddRow(AFirstName, ALastName: string; ASalary: double);
- begin
- ds.Append;
- try
- dsFirstName.Value := AFirstName;
- dsLastName.Value := ALastName;
- dsSalary.Value := ASalary;
- ds.Post;
- except
- ds.Cancel;
- raise;
- end;
- end;
- begin
- if ds.Active then
- ds.Close;
- ds.CreateDataset;
- AddRow('John', 'Smith', 40000);
- AddRow('Joe', 'Garper', 52000);
- AddRow('Hose', 'Enrice', 35000);
- AddRow('Alex', 'Square', 61000);
- end;
-
- procedure TbsPolyglotDemoForm.FillLanguages;
- var
- lPolyglot: TbsCorePolyglot;
- i: Integer;
- begin
- // same dir as exe file
- DataModule1.PolyglotManager.LangsDir := ExtractFileDir(ParamStr(0));
- cbLanguages.Items.Clear;
- lPolyglot := TbsCorePolyglot.GetCorePolyglot;
- for i := 0 to lPolyglot.LangCount - 1 do
- begin
- cbLanguages.Items.Add(lPolyglot.Langs[i]);
- if lPolyglot.Langs[i] = lPolyglot.CurrentLang then
- cbLanguages.ItemIndex := i;
- end;
- end;
-
- procedure TbsPolyglotDemoForm.FormCreate(Sender: TObject);
- begin
- FillDataset;
- FillLanguages;
- end;
-
- procedure TbsPolyglotDemoForm.cbLanguagesChange(Sender: TObject);
- begin
- DataModule1.PolyglotManager.CurrentLang := cbLanguages.Text;
- FillLanguages;
- end;
-
- procedure TbsPolyglotDemoForm.Button1Click(Sender: TObject);
- begin
- MessageDlg(DataModule1.PolyglotManager.GetString('Messages', 'Message1'), mtInformation, [mbOk], 0);
- end;
-
- procedure TbsPolyglotDemoForm.Button2Click(Sender: TObject);
- begin
- MessageDlg(strYouSelected + RadioGroup1.Items.Strings[RadioGroup1.ItemIndex], mtInformation, [mbOk], 0);
- end;
-
- end.
-